from pygnet import client
import time

#class UserHandler(Handler):
#    pass
#    def click(self, x, y):
#        pass

def main():
    client.init('localhost', 1979)
    connection = None

    while not connection:
        client.poll()
        for event_name, args in client.get_events():
            print event_name, args
            if event_name == 'new_connection':
                connection = args['connection']

    for i in xrange(10):
        connection.send_object('hello')
        client.poll()
        for event_name, args in client.get_events():
            print event_name, args
        time.sleep(1)

    client.shutdown()

#    server = Pyro.core.getProxyForURI("PYROLOC://localhost:7766/jokegen")
#    print server.joke("Irmen")
#    handler = UserHandler()
#
#    server.login("asdf")
#    server.registerHandler(handler)
#    server.startSharing()
#
#    server.click(12, 22)
#    #server.getPair("")
#
#    while True:
#        time.sleep(1)
#        print "."



if __name__ == "__main__":
    main()

